{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- sku -->
<link href="__STATIC__/css/sku.css" rel="stylesheet" type="text/css">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>商品库存管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm" onsubmit="return check()">

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品分类：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            {empty name=":input('goods_id')"}
                                                    <div>{$item.goods_title}&nbsp;&nbsp;&nbsp;&nbsp;<a href="{:url('ShopGoods/classify',['id'=>$item['id']])}" class="btn btn-primary">编辑</a></div>
                                                    <input type="hidden" name="goods_id" value="{$item.goods_id}">
                                                    <input type="hidden" name="goods_title" value="{$item.goods_title}">
                                            {else/}
                                                    <div>{:input('goods_title')}&nbsp;&nbsp;&nbsp;&nbsp;<a href="{:url('ShopGoods/classify')}" class="btn btn-primary">编辑</a></div>

                                                    <input type="hidden" name="goods_id" value="{:input('goods_id')}">
                                                    <input type="hidden" name="goods_title" value="{:input('goods_title')}">
                                            {/empty}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品名称：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入店铺商品名称"
                                                   class="form-control col-md-7 col-xs-12" name="title"
                                                   value="{$item.title|default=''}"
                                                   datatype="*"
                                                   nullmsg="请输入店铺商品名称！" errormsg="请输入店铺商品名称！"
                                            >
                                        </div>
                                    </div>



                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">商品描述：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<textarea type="text" placeholder="请填写商品描述,不填写留空"-->
                                                      <!--class="form-control col-md-7 col-xs-12" name="describe">{$item.describe|default=''}</textarea>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">商品单位：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<input type="text" placeholder="请输入商品单位"-->
                                                   <!--class="form-control col-md-7 col-xs-12" name="label"-->
                                                   <!--value="{$item.label|default=''}"-->
                                                   <!--nullmsg="请输入商品单位！" errormsg="请输入商品单位！"-->
                                            <!--&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->



                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">商品规格：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<table class="table table-striped table-bordered table-hover">-->
                                                <!--<thead>-->
                                                <!--<th>规格名称</th>-->
                                                <!--<th>规格参数</th>-->
                                                <!--<th>操作</th>-->
                                                <!--</thead>-->
                                                <!--<tbody id="fieldtr">-->
                                                <!--{present name="$item.id"}-->
                                                    <!--{volist name="flag_list" id="flag_list"}-->
                                                    <!--<tr>-->
                                                        <!--<input type="hidden" value="{$flag_list.id}" name="flag_id[]">-->
                                                        <!--<td><input type="text" name="nameAttr[]" style="width:100px;" value="{$flag_list.flag_name}"/></td>-->
                                                        <!--<td><input type="text" name="valueAttr[]" style="width:100px;" value="{$flag_list.flag_value}"/></td>-->
                                                        <!--<td><a href="javascript:;" onclick="delThis($(this),{$flag_list.id})">删除</a></td>-->
                                                    <!--</tr>-->
                                                    <!--{/volist}-->
                                                <!--{/present}-->
                                                <!--</tbody>-->
                                                <!--<tbody align="right">-->
                                                <!--<tr>-->
                                                    <!--<td colspan="3"><a href="javascript:;" class="addNewTr" title="新增一条">新增一条</a></td>-->
                                                <!--</tr>-->
                                                <!--</tbody>-->
                                            <!--</table>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <!--<div class="divider-dashed"></div>-->


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品价格：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入价格"
                                                   class="form-control col-md-7 col-xs-12" name="price"
                                                   value="{$item.price|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">原价：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入价格"
                                                   class="form-control col-md-7 col-xs-12" name="market_price"
                                                   value="{$item.market_price|default=''}"
                                            >
                                        </div>
                                    </div>

                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">成 本 价：</label>-->
                                        <!--<div class="col-md-1 col-sm-6 col-xs-12">-->
                                            <!--<input type="text" placeholder="请输入成本价"-->
                                                   <!--class="form-control col-md-7 col-xs-12" name="cost_price"-->
                                                   <!--value="{$item.cost_price|default=''}"-->
                                            <!--&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品总库存：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写库存" readonly
                                                   class="form-control col-md-7 col-xs-12" name=""
                                                   value="{$inventory_sum|default=''}"
                                            >
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品总销量：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="商品销量"
                                                   class="form-control col-md-7 col-xs-12" name="sale_number" readonly
                                                   value="{$item.sale_number|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <input type="hidden" name="activity" value="{$item.activity|default=''}">


                                    <div class="form-group" style="width: 80%;margin-left: 17%">

                                        {volist name='attr' id='attrList'}
                                        <dl nc_type="spec_group_dl_{$key}"
                                            nctype="spec_group_dl"
                                            {eq name='$key' value='0'}spec_img="t"{/eq}
                                        >
                                        <dt>
                                            <input name="sp_name[{$attrList.id}]" type="text"
                                                   style="width: 100px;text-align: right"
                                                   class="form-control" value="{$attrList.title}"
                                                   nctype="spec_name" disabled data-param="{id:{$attrList.id},name:'{$attrList.title}'}"/>
                                            </dt>
                                        <dd
                                                {eq name='$key' value='0'}nctype="sp_group_val"{/eq}
                                        >
                                        <ul class="spec" style="margin-left: 7%">
                                            {volist name='attrList.attribute' id='attributeList'}
                                            <li>
                                                    <span nctype="input_checkbox">
                                                      <input type="checkbox" value="{$attributeList.title}"
                                                             nc_type="{$attributeList.id}"
                                                             {eq name='$key' value='0'}class="sp_val"{/eq}
                                                             name="sp_val[{$attrList.title}][{$attributeList.id}]">
                                                    </span>
                                                <span nctype="pv_name">{$attributeList.title}</span></li>
                                            {/volist}

                                            {empty name='item.goods_id'}
                                            <li data-param="{'gc_id':'{:input('goods_id')}','sp_id':'{$attrList.id}','sp_title':'{$attrList.title}','url':'{:url('ShopGoodsSpec/attrCreate')}'}">
                                            {else/}
                                            <li data-param="{'gc_id':'{$item.goods_id}','sp_id':'{$attrList.id}','sp_title':'{$attrList.title}','url':'{:url('ShopGoodsSpec/attrCreate')}'}">
                                            {/empty}
                                                <div nctype="specAdd1"><a href="javascript:void(0);" class="ncsc-btn" nctype="specAdd">设置属性值</a></div>
                                                <div nctype="specAdd2" style="display:none;width: 200px;">
                                                    <input class="form-control" style="width: 80px;float: left" type="text" placeholder="属性值名称" maxlength="20">
                                                    <a href="javascript:void(0);" nctype="specAddSubmit" class="ncsc-btn ncsc-btn-acidblue" style="margin-left: 5px;">确认</a>
                                                    <a href="javascript:void(0);" nctype="specAddCancel" class="ncsc-btn ncsc-btn-orange">取消</a>
                                                </div>
                                            </li>
                                        </ul>
                                        </dd>
                                        </dl>
                                        {/volist}
                                        <div class="in"></div>
                                        <dl nc_type="spec_dl" class="spec-bg" style="display:none" id="liu0">
                                            <dt>默认库存配置：</dt>
                                            <dd class="spec-dd">
                                                <table border="0" cellpadding="0" cellspacing="0" class="spec_table">
                                                    <thead>
                                                    {volist name='attr' id='attrList2'}
                                                    <th nctype="spec_name_{$attrList2.id}">{$attrList2.title}</th>
                                                    {/volist}
                                                    <th class="w60">
                                                        库　存
                                                        <div class="batch"><b class="icon-edit" title="批量操作"><img style="margin-top: -5px;" src="__STATIC__/images/edit_blue.png" width="10" height="10"></b>
                                                            <div class="batch-input" style="display:none;">
                                                                <h6>批量设置库存：</h6>
                                                                <a href="javascript:void(0)" class="close">X</a>
                                                                <input name="" type="text" class="text stock">
                                                                <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="stock">设置</a><span class="arrow"></span></div>
                                                        </div>
                                                    </th>
                                                    <!--<th class="w100">货号</th>-->
                                                    </thead>
                                                    <tbody nc_type="spec_table">
                                                    </tbody>
                                                </table>
                                            </dd>
                                        </dl>

                                    </div>
                                    <script>


                                        function fl(){

                                            var i = 0;
                                            var content = $('#liu0').html();
                                            var arr = [];
                                            var arri =[];
                                            $(".choose_check input").each(function(k,v){
                                                //  console.log(k);

                                                var ret = $(this).is(':checked');
                                                var name = $(this).parent().text();
                                                var shop_id = $(this).val();

                                                if(ret){
                                                    arri.push(shop_id);
                                                    arr.push(name);

                                                    ++i;
                                                    //$(".in").append($("#liu0").clone(true).attr('id','liu'+i));
                                                }else{
                                                    //$('.in').append($('#liu0').html(''));
                                                }
                                            });
                                            //console.log(arr);
                                            var oid = 0+i;


                                            $('.in').html('');
                                            for(var j=0;j<=i-1;j++){
                                                //console.log(arr[j]);
                                                $('.in').append($('#liu0').clone().attr('id','liu0'+j));
                                                    //    console.log(1);
                                                $('#liu0'+j).find("[data_type='stock']").css("background-color","#B2E0FF");
                                                //$('#liu0'+j).find("[data_type='stock']").css("background-color","#B2E0FF");
                                                $('#liu0'+j).find("[name]").each(function(v,k){
                                                    //alert($(this).attr("name"))
                                                    var name = $(this).attr("name");
                                                  //  console.log('2 '+name+' 4');
                                                   // console.log('3');
                                                    var left = name.substr(0,4);
                                                    var right = name.substr(4);
                                                    var last = 'new'+'['+arri[j]+']'+right;
                                                   /// $(this).attr("name",last);
                                                });
                                                var stock =  $('#liu0'+j).find("[data_type='stock']").attr("name");

                                                $('#liu0'+j).find('dt').text(arr[j]);
                                                oid+=1;
                                            }
                                        }



                                        $('#a').click(function(){
                                            $('#liu00').find("[data_type='stock']").css("background-color","#B2E0FF");
                                        });

                                        $('.choose_input').click(function(){
                                            var i = 0;
                                            var content = $('#liu0').html();
                                            var arr = [];
                                            var arri =[];
                                            $(".choose_check input").each(function(k,v){
                                              //  console.log(k);

                                                var ret = $(this).is(':checked');
                                                var name = $(this).parent().text();
                                                var shop_id = $(this).val();

                                                if(ret){
                                                    arri.push(shop_id);
                                                    arr.push(name);
                                                    ++i;
                                                    //$(".in").append($("#liu0").clone(true).attr('id','liu'+i));
                                                }else{
                                                    //$('.in').append($('#liu0').html(''));
                                            }
                                            });

                                            //console.log(arr);
                                            var oid = 0+i;
                                            $('.in').html('');
                                            for(var j=0;j<=i-1;j++){
                                                //console.log(arr[j]);
                                                var  shop_id = arri[j];
                                                var id = {:input('id',0)};
                                                $('.in').append($('#liu0').clone().attr('id','liu0'+j));
                                                $('#liu0'+j).find("[name]").css("background-color","#B2E0FF");
                                                $('#liu0'+j).find('[name]').each(function(k,v){
                                                    //alert($(this).attr("name"))
                                                        var name = $(this).attr("name");

                                                        var left = name.substr(0,4);
                                                        var right = name.substr(4);
                                                        var last = 'new'+'['+arri[j]+']'+right;
                                                        $(this).attr("name",last);



                                                           // alert(vv);

                                                });


                                                $('#liu0'+j).find('dt').text(arr[j]);
                                                oid+=1;

                                            $('#liu0'+j).find("[data_type='stock']").each(function(k,v){
                                                var c = {:count($attr)};

//                                                   var vv1 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().children("input").val();
//                                                   var vv2 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().prev().children("input").val();
                                                if(c == 1){
                                                    var vv =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().children("input").val();

                                                }else if(c == 2){
                                                    var vv1 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().children("input").val();

                                                    var vv2 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().prev().children("input").val();
                                                    var vv = vv2+','+vv1;

                                                }else if(c ==3){
                                                    var vv1 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().children("input").val();
                                                    var vv2 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().prev().children("input").val();
                                                    var vv3 =  $('#liu0'+j).find("[data_type='stock']").eq(k).parent().prev().prev().prev().children("input").val();
                                                    var vv = vv3+','+vv2+','+vv1;
                                                }else if(c ==4) {
                                                    var vv1 = $('#liu0' + j).find("[data_type='stock']").eq(k).parent().prev().children("input").val();
                                                    var vv2 = $('#liu0' + j).find("[data_type='stock']").eq(k).parent().prev().prev().children("input").val();
                                                    var vv3 = $('#liu0' + j).find("[data_type='stock']").eq(k).parent().prev().prev().prev().children("input").val();
                                                    var vv4 = $('#liu0' + j).find("[data_type='stock']").eq(k).parent().prev().prev().prev().prev().children("input").val();
                                                    var vv = vv4+','+vv3+','+vv2+','+vv1;
                                                }

                                                {eq name='$Request.action' value='update'}  aj(j,shop_id,id,vv,k);

                                                {/eq}
                                            });
                                            var pu = arri.join(',');
                                            }


                                           // $('#liu0').css({display:"none"});

                                        });
                                        var arr = [];
                                        var arri =[];
                                        var i = 0;

                                        function aj(j,shop_id,id,vv,k){

                                            $.ajax({
                                                url: "{:url('kc')}",
                                                data:{shop_id:shop_id,goods_id:id,attr:vv},
                                                dataType: 'json',
                                                success: function (data) {

                                                    if(data >0){
                                                        $('#liu0'+j).find("[data_type='stock']").eq(k).val(data);
                                                        console.log('d'+data);

                                                    }



                                                    // var obj = JSON.parse(data);
                                                    // var c = obj.length;
                                                    //console.log(c);
                                                    //$.each(obj,function(index,value){
                                                    //  console.log('ajax');
                                                    // $("[data_type='stock']").eq(index).val(value);
                                                    //$('#liu0'+index).find("[name]").css("background-color","#B2E0FF");

                                                    //});
                                                }
                                            });

                                        }
                                    </script>
                                    <style>

                                        .blue { background:blue; display: block;padding: 50px;}
                                    </style>
                                    <div class="abc" style="display: none;"><li></li><li><input type="text" data_type="stock"/></li></div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">图片上传(列表)：【332*332】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <div id="imgdiv">
                                                <img id="imgShow" src="__PUBLIC__/{$item.picUrl|default=''}"
                                                     width="200" height="190" onerror="this.src='__STATIC__/images/default.png'"
                                                     />
                                            </div>
                                            <div class="uploader white">
                                                <input type="text" class="filename" name="picUrl"
                                                       value="{$item.picUrl|default=''}" readonly/>
                                                <input type="button" name="file" class="button" value="上传..."/>
                                                <input type="file" id="up_img" name="picUrl"
                                                       value='{$item.picUrl|default=""}'/>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">上传组图：【720*720】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">

                                            <div class="uploader white">
                                                <input type="button" id="logo_upload_btn" class="button" value="批量上传"/>
                                            </div>

                                            <div id="logo_upload_area" style='width:80%'>
                                                <div id='photos_area' class="photos_area clearfix">

                                                    {if condition="($Request.action eq 'update') && ($item.picArr neq 'N;')"}
                                                        {foreach :unserialize($item['picArr']) as $picValue}
                                                            <div class="item">
                                                                <input type="hidden" name="picArr[]" value="{$picValue}">
                                                                <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">
                                                                <div class="operate">
                                                                    <i class="toleft">左移</i>
                                                                    <i class="toright">右移</i>
                                                                    <i class="del">删除</i>
                                                                </div>
                                                            </div>
                                                        {/foreach}
                                                    {/if}

                                                </div>
                                                <div class="alert alert-success" role="alert"
                                                     style="margin:10px 0;"><strong><span
                                                        class="glyphicon glyphicon-flag"></span>点击批量上传按钮上传多张图片:</strong>&nbsp;&nbsp;单张图片大小不超过500KB,格式为jpg,png,gif,jpeg
                                                </div>

                                            </div>

                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品内容：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea type="text/plain" style=" height: 300px; width: 100%" id="containers"
                                                      name="content"
                                                      placeholder="请输入商品内容">
                                                {$item.content|default=''}
                                            </textarea>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">购买须知：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea type="text/plain" style=" height: 300px; width: 100%" id="containerss"
                                                      name="buy_must_know"
                                                      placeholder="请输入购买须知内容">
                                                {$item.buy_must_know|default=''}
                                            </textarea>
                                        </div>
                                    </div>

                                    <!--<div class="divider-dashed"></div>-->
                                    <!--{eq name=":request()->action()" value='update'}-->
                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">浏览次数：</label>-->
                                        <!--<div class="col-md-1 col-sm-6 col-xs-12">-->
                                            <!--<input type="text" placeholder="请填写排序"-->
                                                   <!--class="form-control col-md-7 col-xs-12" name="hits" disabled-->
                                                   <!--value="{$item.hits|default='0'}"-->
                                            <!--&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->
                                    <!--{/eq}-->
                                    <!--<div class="divider-dashed"></div>-->


                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">运费状态：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="freight_type" id="freight_type_1" class="cartradio"-->
                                                       <!--value="1"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择运费类型！" errormsg="请选择运费类型！"-->
                                                       <!--{eq name='item.freight_type|default=""' value='1' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="freight_type_1"></label>-->
                                                <!--<span>固定运费</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="freight_type" id="freight_type_2" class="cartradio"-->
                                                       <!--value="2"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择运费类型！" errormsg="请选择运费类型！"-->
                                                       <!--{eq name='item.freight_type|default=""' value='2' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="freight_type_2"></label>-->
                                                <!--<span>免运费</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                            <!--&lt;!&ndash;<label class="radio_box">&ndash;&gt;-->
                                                <!--&lt;!&ndash;<input type="radio" name="freight_type" id="freight_type_3" class="cartradio"&ndash;&gt;-->
                                                       <!--&lt;!&ndash;value="3"&ndash;&gt;-->
                                                       <!--&lt;!&ndash;datatype="*"&ndash;&gt;-->
                                                       <!--&lt;!&ndash;nullmsg="请选择运费类型！" errormsg="请选择运费类型！"&ndash;&gt;-->
                                                       <!--&lt;!&ndash;{eq name='item.freight_type|default=""' value='3' }&ndash;&gt;-->
                                                       <!--&lt;!&ndash;checked&ndash;&gt;-->
                                                       <!--&lt;!&ndash;{/eq}&ndash;&gt;-->
                                                <!--&lt;!&ndash;&gt;&nbsp;&nbsp;&ndash;&gt;-->
                                                <!--&lt;!&ndash;<label for="freight_type_3"></label>&ndash;&gt;-->
                                                <!--&lt;!&ndash;<span>运费模板</span>&ndash;&gt;-->
                                                <!--&lt;!&ndash;&nbsp;&nbsp;&ndash;&gt;-->
                                            <!--&lt;!&ndash;</label>&ndash;&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <div class="form-group" id="31232" style="display: block">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">运费金额：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写固定运费"
                                                   class="form-control col-md-7 col-xs-12" name="freight" id="3123"
                                                   value="{$item.freight|default='0'}"
                                            >
                                        </div>
                                    </div>

                                    <div class="form-group" id="31232" style="display: block">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">排序：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写排序"
                                                   class="form-control col-md-7 col-xs-12" name="sort" id="3123"
                                                   value="{$item.sort|default='0'}"
                                            >
                                        </div>
                                    </div>

                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">促销状态：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="promotion" id="promotion_1" class="cartradio"-->
                                                       <!--value="1"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.promotion|default=""' value='1' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="promotion_1"></label>-->
                                                <!--<span>启用</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="promotion" id="promotion_2" class="cartradio"-->
                                                       <!--value="2"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.promotion|default=""' value='2' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="promotion_2"></label>-->
                                                <!--<span>禁用</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">推荐状态：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="recommend" id="recommend_1" class="cartradio"-->
                                                       <!--value="1"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.recommend|default=""' value='1' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="recommend_1"></label>-->
                                                <!--<span>启用</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="recommend" id="recommend_2" class="cartradio"-->
                                                       <!--value="2"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.recommend|default=""' value='2' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="recommend_2"></label>-->
                                                <!--<span>禁用</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <!--<div class="divider-dashed"></div>-->

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">上架状态：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <label class="radio_box">
                                                <input type="radio" name="state" id="state_1" class="cartradio"
                                                       value="1"
                                                       datatype="*"
                                                       nullmsg="请选择启用状态！" errormsg="请选择启用状态！"
                                                       {eq name='item.state|default=""' value='1' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="state_1"></label>
                                                <span>上架</span>
                                                &nbsp;&nbsp;
                                            </label>
                                            <label class="radio_box">
                                                <input type="radio" name="state" id="state_2" class="cartradio"
                                                       value="2"
                                                       datatype="*"
                                                       nullmsg="请选择启用状态！" errormsg="请选择启用状态！"
                                                       {eq name='item.state|default=""' value='2' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="state_2"></label>
                                                <span>下架</span>
                                                &nbsp;&nbsp;
                                            </label>
                                        </div>
                                    </div>

                                   {include file="auding_status" /}



                                    <div class="ln_solid"></div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {present name="$item.id"}
                                            <input type="hidden" name="id" value="{$item.id}">
                                            <input type="hidden" name="repId" id="repId" value="{$item.parenTid}"/>
                                            {/present}
                                            {notempty name=":input('condition')"}
                                            <input type="hidden" name="status" value="2">
                                            {/notempty}
                                            <input type="hidden" name="member_id" value="{:session('shop_id')}"/>
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- select -->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>

<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    function check(){
        {volist name='attr' id='attrList5'}
        var n_{$key} = $('dl[nc_type="spec_group_dl_{$key}"]').find('input[type="checkbox"]:checked');
        if($('dl[nc_type="spec_group_dl_{$key}"] input[type="checkbox"]').is(':checked') == false) {
            layer.msg('请选择{{$attrList5.title}}属性');
            return false;
        }
        {/volist}
            {eq name='$Request.action' value='update'}

            var i = 0;
            var content = $('#liu0').html();
            var arr = [];
            var arri =[];

            $(".choose_check input").each(function(k,v){
                //  console.log(k);

                var ret = $(this).is(':checked');
                var name = $(this).parent().text();
                var shop_id = $(this).val();

                if(ret){
                    arri.push(shop_id);
                    arr.push(name);
                    ++i;
                    //$(".in").append($("#liu0").clone(true).attr('id','liu'+i));
                }else{
                    //$('.in').append($('#liu0').html(''));
                }
            });
            //console.log(arr);
            var oid = 0+i;



            for(var j=0;j<=i-1;j++){
                //console.log(arr[j]);
                $('.in').append($('#liu0').clone().attr('id','liu0'+j));
                //    console.log(1);
                $('#liu0'+j).find("[data_type='stock']").css("background-color","#B2E0FF");
                //$('#liu0'+j).find("[data_type='stock']").css("background-color","#B2E0FF");
                $('#liu0'+j).find("[name]").each(function(v,k){
                    //alert($(this).attr("name"))
                    var name = $(this).attr("name");
                    //  console.log('2 '+name+' 4');
                    // console.log('3');
                    var three = name.substr(0,3);
                    if(three != 'new'){
                        var left = name.substr(0,4);
                        var right = name.substr(4);
                        var last = 'new'+'['+arri[j]+']'+right;
                        $(this).attr("name",last);
                    }

                });
                var stock =  $('#liu0'+j).find("[data_type='stock']").attr("name");

                $('#liu0'+j).find('dt').text(arr[j]);
                oid+=1;
            }
            {/eq}


        }


</script>
<script>


    // validform
    $(function () {

        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });

        // 实例化编辑器
        var ue = UE.getEditor('containers');
        var ue = UE.getEditor('containerss');

        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});

        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });

        // 组图排序 删除图片
        $(".toleft").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_left = item.prev(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_left.length == 0) {
                    item.insertAfter($("#photos_area").children(".item:last"));
                } else {
                    item.insertBefore(item_left);
                }
            }

        })

        $(".toright").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_right = item.next(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_right.length == 0) {
                    item.insertBefore($("#photos_area").children(".item:first"));
                } else {
                    item.insertAfter(item_right);
                }
            }
        })

        $(".del").live("click", function () {
            $(this).parent().parent(".item").remove();
        })

        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                }else{
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "/index.php/client/shop_goods/uploadarr.html",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '50000kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();

    <!-- attr -->

    // 按规格存储规格值数据
    var spec_group_checked = ['','',''];
    var str = '';
    var V = new Array();

    {volist name='attr' id='attrList3'}
    var spec_group_checked_{$key} = new Array();
    {/volist}

    $(function(){


        $('dl[nctype="spec_group_dl"]').on('click', 'span[nctype="input_checkbox"] > input[type="checkbox"]',function(){
            into_array();
            goods_stock_set();
        });

        // 提交后不没有填写的价格或库存的库存配置设为默认价格和0
        // 库存配置隐藏式 里面的input加上disable属性
        $('input[type="submit"]').click(function(){
            $('input[data_type="marketprice"]').each(function(){
                if($(this).val() == ''){
                    $(this).val($('input[name="market_price"]').val());
                }
            });
            $('input[data_type="price"]').each(function(){
                if($(this).val() == ''){
                    $(this).val($('input[name="price"]').val());
                }
            });
            $('input[data_type="stock"]').each(function(){
                if($(this).val() == ''){
                    $(this).val('0');
                }
            });
            $('input[data_type="alarm"]').each(function(){
                if($(this).val() == ''){
                    $(this).val('0');
                }
            });
            if($('dl[nc_type="spec_dl"]').css('display') == 'none'){
                $('dl[nc_type="spec_dl"]').find('input').attr('disabled','disabled');
            }
        });

    });

    function delThisTr(trobj)
    {
        trobj.parent().parent().remove();
    }

    function delThis(trobj,id)
    {
        if(confirm('确认删除？')){
            $.ajax({
                url : '{:url("ShopGoodsFlag/destroy")}',
                data:{'id':id},
                dataType:'html',
                success:function(data){
                    if(data == 'true'){
                        layer.msg('删除成功');
                        trobj.parent().parent().remove();
                    }else{
                        layer.msg('网络繁忙,请重试');
                    }
                }
            });
        }
    }
    $(".addNewTr").click(function(){
        str = '<tr><td><input type="text" name="nameAttr[]" style="width:100px;"/></td>' +
            '<td><input type="text" name="valueAttr[]" style="width:100px;" /></td>' +
            '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
        $("#fieldtr").append(str);
    });

    // 将选中的规格放入数组
    function into_array(){

        {volist name='attr' id='attrList4'}
        spec_group_checked_{$key} = new Array();
        $('dl[nc_type="spec_group_dl_{$key}"]').find('input[type="checkbox"]:checked').each(function(){
            i = $(this).attr('nc_type');
           // alert(i);
            v = $(this).val();
            c = null;
            if ($(this).parents('dl:first').attr('spec_img') == 't') {
                c = 1;
            }
            spec_group_checked_{$key}[spec_group_checked_{$key}.length] = [v,i,c];
        });

        spec_group_checked[{$key}] = spec_group_checked_{$key};

        {/volist}

    }

    // 生成库存配置
    function goods_stock_set(){
        //  店铺价格 商品库存改为只读
      //  $('input[name="market_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
       // $('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
       // $('input[name="inventory"]').attr('readonly','readonly').css('background','#E7E7E7 none');

        $(".choose_check input").each(function(k,v){
            //  console.log(k);

            var ret = $(this).is(':checked');

            if(ret){
                ++i;
                    $(this).attr('checked',false);
                    $('.in').html('');
                //$(".in").append($("#liu0").clone(true).attr('id','liu'+i));
            }else{
                //$('.in').append($('#liu0').html(''));
            }
        });
        $('dl[nc_type="spec_dl"]').show();
        str = '<tr>';
        {:SpecSku(0,count($attr))}
        if(str == '<tr>'){
            //  店铺价格 商品库存取消只读
           // $('input[name="market_price"]').removeAttr('readonly').css('background','');
            //$('input[name="price"]').removeAttr('readonly').css('background','');
            $('input[name="inventory"]').removeAttr('readonly').css('background','');
            $('dl[nc_type="spec_dl"]').hide();
        }else{
            $('tbody[nc_type="spec_table"]').empty().html(str)
                    .find('input[nc_type]').each(function(){
                        s = $(this).attr('nc_type');
                        //console.log($(this).val(V[s]));
                try{$(this).val(V[s]);}catch(ex){$(this).val('');};
                if($(this).attr('data_type') == 'marketprice' && $(this).val() == ''){
                    $(this).val($('input[name="market_price"]').val());
                }
                if($(this).attr('data_type') == 'price' && $(this).val() == ''){
                    $(this).val($('input[name="price"]').val());
                }
                if($(this).attr('data_type') == 'stock' && $(this).val() == ''){
                    $(this).val('0');
                }
            }).end()
                    .find('input[data_type="stock"]').change(function(){

                computeStock();    // 库存计算
            }).end()
                    .find('input[data_type="marketprice"]').change(function(){

                computeMarketPrice();     // 市场价价格计算
            }).end()
                    .find('input[data_type="price"]').change(function(){
                computePrice();     // 价格计算
            }).end()
                    .find('input[nc_type]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
        }
    }

    {eq name='$Request.action' value='update'}
    //  编辑商品时处理JS
    $(function(){

        var E_SP = new Array();
        var E_SPV = new Array();

        {volist name='item.spec_attr' id='SpecAttrList'}

        {foreach :unserialize($SpecAttrList['attr']) as $key=>$value}
        E_SP['{$key}'] = '{$value}';
        {/foreach}

        E_SPV['{$SpecAttrList.attribute_id}|id'] = '{$SpecAttrList.id}';E_SPV['{$SpecAttrList.attribute_id}|marketprice'] = '{$SpecAttrList.market_price}';E_SPV['{$SpecAttrList.attribute_id}|price'] = '{$SpecAttrList.price}';E_SPV['{$SpecAttrList.attribute_id}|stock'] = '{$SpecAttrList.inventory}';E_SPV['{$SpecAttrList.attribute_id}|alarm'] = '{$SpecAttrList.inventory_hint}';E_SPV['{$SpecAttrList.attribute_id}|sku'] = '{$SpecAttrList.style_id}';

        {/volist}
        V = E_SPV;

        {notempty name='attr'}
            $('dl[nc_type="spec_dl"]').show();

            $('dl[nctype="spec_group_dl"]').find('input[type="checkbox"]').each(function(){
                //  店铺价格 商品库存改为只读
               // $('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
               // $('input[name="market_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
                $('input[name="inventory"]').attr('readonly','readonly').css('background','#E7E7E7 none');
                s = $(this).attr('nc_type');

                if (!(typeof(E_SP[s]) == 'undefined')){
                    $(this).attr('checked',true);
                    v = $(this).parents('li').find('span[nctype="pv_name"]');

                    if(E_SP[s] != ''){

                        $(this).val(E_SP[s]);
                        v.html('<input type="text" class="text" maxlength="20" value="'+E_SP[s]+'" />');
                    }else{

                        v.html('<input type="text" class="text" maxlength="20" value="'+v.html()+'" />');
                    }
                    //change_img_name($(this));			// 修改相关的颜色名称
                }
            });
           // alert("{:ff()}");

            var adf = {:count($attr)};
            into_array();	// 将选中的规格放入数组
            str = '<tr>';
            {:SpecSku(0,count($attr))}
            if(str == '<tr>'){
                $('dl[nc_type="spec_dl"]').hide();
                $('input[name="price"]').removeAttr('readonly').css('background','');
                $('input[name="market_price"]').removeAttr('readonly').css('background','');
                $('input[name="inventory"]').removeAttr('readonly').css('background','');
            }else{
                //console.log(str);
                $('tbody[nc_type="spec_table"]').empty().html(str)
                        .find('input[nc_type]').each(function(){
                    s = $(this).attr('nc_type');
                   // console.log(str)+'--------';
                    //console.log(s);

                }).end()
                        .find('input[data_type="stock"]').change(function(){
                    computeStock();    // 库存计算
                }).end()
                        .find('input[data_type="marketprice"]').change(function(){
                    computeMarketPrice();     // 市场价价格计算
                }).end()
                        .find('input[data_type="price"]').change(function(){
                    computePrice();     // 价格计算
                }).end()
                        .find('input[type="text"]').change(function(){
                    s = $(this).attr('nc_type');
                    V[s] = $(this).val();
                });
            }

         {/notempty}
        });
        $(".choose_check input").each(function(k,v){
            //  console.log(k);
            var ret = $(this).is(':checked');
            var name = $(this).parent().text();
            var shop_id = $(this).val();

            if(ret){
                ++i;
                arri.push(shop_id);
                arr.push(name);

                //$(".in").append($("#liu0").clone(true).attr('id','liu'+i));
            }else{
                //$('.in').append($('#liu0').html(''));
            }

        });
        var prm = arri.join(',');
        console.log(arri.join(','));
        var id = {:input('id')};
        fl();
        setTimeout(function(){ $.ajax({
            url: "{:url('inv')}",
            data:{shop_id:prm,goods_id:id},
            dataType: 'json',
            async:false,
            success: function (data) {
                console.log(data);
                var obj = JSON.parse(data);
                var c = obj.length;
                console.log(c);
                $.each(obj,function(index,value){
                    $("[data_type='stock']").eq(index).val(value);
                });
            }
        }); }, 300);


        //var pos =$(":input").css('display','block');
           // console.log(pos);

    {/eq}


</script>
<script type="text/javascript">
    var str = '<a href="http://www.baidu.com">链接111111111</a> ';
    var reg1 = /href=\"(.+)\"/g;
    var reg2 = /\">(.+)<\/a>/g;
    var retVal1 = reg1.exec(str);
    var retVal2 = reg2.exec(str);
    //alert(retVal1[1]);
    //alert(retVal2[1]);
</script>
<script src="__STATIC__/js/sku.js"></script>
</body>

</html>
